ActionController::Routing::Routes.draw do |map|
  map.resources :feedbacks

  map.resources :region_descriptions

  # Application root (what shows up on front page)
  map.root :controller => "home", :action => "index"
  
  map.resources :users
  
  map.resources :artwork_categories
  map.connect '/categories/ajax_results', :controller => 'categories', :action => 'ajax_results'
  map.resources :categories
  map.resources :medias
  map.resources :regions
  map.resources :artists
  map.resources :artworks, :controller => "catalogue"
  
  map.namespace :admin do |admin|
    #    admin.resources :artworks do |artwork|
    #      artwork.resources :medias
    #      artwork.resources :artwork_descriptions
    #    end
    admin.resources :categories, :has_many => [:artworks, :category_descriptions]
    admin.resources :artworks, :has_many => [:medias, :artwork_descriptions, :categories]
    
    admin.resources :artists, :has_many => [:medias, :artist_descriptions, :artworks],
    :member => { :map => :get }
    
    admin.resources :orders
    admin.resources :feedbacks
  end
  
  map.resource  :session
  
  map.register 'register', :controller => 'users', :action => 'new'
  map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate'
  
  map.login 'login', :controller => 'sessions', :action => 'new'
  map.logout 'logout', :controller => 'sessions', :action => 'destroy'
  
  map.forgot_password 'forgot_password', :controller => 'users', :action => 'forgot_password'
  map.change_password 'change_password', :controller => 'users', :action => 'change_password'
  
  map.admin 'admin', :controller => 'admin', :action => 'index'
  map.superadmin 'superadmin', :controller => 'superadmin', :action => 'index'
  
  # BAD encapsulation needs MAJOR refactoring. : (  How embarassing.
  map.region_media 'region_media', :controller => 'superadmin', :action => 'region_media' 
  map.region_description 'region_description', :controller => 'superadmin', :action => 'region_description' 
  
  # The priority is based upon order of creation: first created -> highest priority.
  
  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action
  
  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)
  
  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products
  
  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
  
  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  
  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end
  
  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  # map.root :controller => "welcome"
  
  # See how all your routes lay out with "rake routes"
  
  # Install the default routes as the lowest priority.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end
